home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7445 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: prairienet.org!sjmccaug
  2. From: sjmccaug@prairienet.org (Scott J. McCaughrin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: pow(-1,1.1) = DOMAIN error
  5. Date: 23 Feb 1996 10:35:28 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <4gk59g$mko@vixen.cso.uiuc.edu>
  8. References: <96053.171141DSEAMA41@portland.caps.maine.edu> <Christian.Straka.15.0010E3C9@uni-konstanz.de>
  9. Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
  10. NNTP-Posting-Host: firefly.prairienet.org
  11.  
  12.  
  13. In a previous article, DSEAMA41@portland.caps.maine.edu (Starduster) says:
  14.  
  15. >In article <Christian.Straka.15.0010E3C9@uni-konstanz.de>,
  16. >Christian.Straka@uni-konstanz.de (Christian Straka) says:
  17. >>The pow() and powl() function in <math.h> doesn't work properly. The following
  18. >>example causes a DOMAIN error exception (see defs in math.h):
  19. >>
  20. >>             pow(-1,1.1);
  21. >>
  22. >>Has anyone an idea to fix this problem?
  23.  The problem lies in the way 'pow' is implemented via logarithms: 
  24.              pow(x,y) = (e^ln(x))^y = e^(y*ln(x)).
  25.  So pow(-1,y) = e^(y*ln(-1)) which bombs because natural log (ln) can't take
  26.  negative arguments (or 0) over the reals. That is, negatives and zero are
  27.  not in the domain of ln.
  28.  
  29.  -- Scott
  30.  
  31.